/**
 * 
 */
package stc.skymobi.launcher;

import static org.junit.Assert.*;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.LazyDynaBean;
import org.apache.commons.beanutils.PropertyUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author Marvin.Ma
 *
 */
public class DynaBeanTestCase {

	/**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testLazyDynClass() throws Exception {
		DynaBean bean = new LazyDynaBean();
		
		assertNull( PropertyUtils.getProperty(bean, "name") );
		
		bean.set("name", "marvin");
		
		assertEquals( PropertyUtils.getProperty(bean, "name"), "marvin" );
		
		assertNull( PropertyUtils.getProperty(bean, "age") );
		
		bean.set("age", 34);
		
		assertEquals( PropertyUtils.getProperty(bean, "age"), 34 );
	}
}
